{
  LX Item module

  Based on modo's SDK lxiem.h which is:

  Copyright (c) 2008-2012 Luxology LLC

  Permission is hereby granted, free of charge, to any person obtaining a
  copy of this software and associated documentation files (the "Software"),
  to deal in the Software without restriction, including without limitation
  the rights to use, copy, modify, merge, publish, distribute, sublicense,
  and/or sell copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.   Except as contained
  in this notice, the name(s) of the above copyright holders shall not be
  used in advertising or otherwise to promote the sale, use or other dealings
  in this Software without prior written authorization.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  DEALINGS IN THE SOFTWARE.
}

{
  Copyright (c) 2012 David Ballesteros and Jameel Halabi

  This unit is part of the BLAISEmodo wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}


unit Lx_Item;

{$mode objfpc}{$H+}

interface

uses
  Lx_Result, Lx_Value, Lx_VMath;

const
  LXa_CHANNELGRAPH         = 'channelgraph' ;
  LXa_ITEM                 = 'item'         ;
  LXa_ITEMGRAPH            = 'itemgraph'    ;
  LXa_SCENE                = 'scene2'       ;
  LXa_SCENEGRAPH           = 'scenegraph'   ;
  LXa_SCENESERVICE         = 'sceneservice3';
  LXa_SCENE2SERVICE        = 'sceneservice2';

  LXf_LOADIMG_SEARCH_PATHS =   1;
  LXf_LOADIMG_USER_REPLACE =   2;

  LXfSCENENAME_STAR        =   1;
  LXfSCENENAME_SHORT       =   2;

  LXiTYPE_ANY              =  -1;
  LXiTYPE_NONE             =   0;

  LXiCHANTYPE_NONE         =   0;
  LXiCHANTYPE_INTEGER      =   1;
  LXiCHANTYPE_FLOAT        =   2;
  LXiCHANTYPE_GRADIENT     =   3;
  LXiCHANTYPE_STORAGE      =   4;
  LXiCHANTYPE_EVAL         =   5;
  LXiCHANMODE_SCALAR       =   0;
  LXiCHANMODE_XY           =   1;
  LXiCHANMODE_XYZ          =   2;
  LXiCHANMODE_RGB          =   3;
  LXiCHANMODE_RGBA         =   4;
  LXfITEMLOAD_IMPORT       = $01;
  LXfITEMLOAD_CURRENT      = $02;

  LXu_CHANNELGRAPH         = '{F70C8AD7-C15F-42e7-98F6-4C4C7F6D577E}';
  LXu_ITEM                 = '{7FF2D6D5-5E28-4650-93ED-89FF257F9629}';
  LXu_ITEMGRAPH            = '{C34D7C65-031A-4c9d-8C01-3187D383937B}';
  LXu_SCENE                = '{FF870F44-FED9-4dbc-95BA-2972A43FC936}';
  LXu_SCENEGRAPH           = '{FE07D3C5-C7E4-46af-8F0A-5AB173D48445}';
  LXu_SCENESERVICE         = '{50190141-0059-48FE-B27D-6C98E1348D7B}';
  LXu_SCENE2SERVICE        = '{3B1E02DD-8ACA-4f30-99C4-F87B626D4FA3}';

type
  PLXtItemType = ^LXtItemType;
  LXtItemType  = Integer     ;

  LXtTransformType = (LXiXFRM_SCALE      ,
                      LXiXFRM_ROTATION   ,
                      LXiXFRM_POSITION   ,
                      LXiXFRM_PIVOT      ,
                      LXiXFRM_PIVOT_C    ,
                      LXiXFRM_SHEAR      ,
                      LXiXFRM_PIVOT_ROT  ,
                      LXiXFRM_PIVOT_ROT_C) ;

  ILxSceneService = interface
  [LXu_SCENESERVICE]
    function ScriptQuery
             (  out VObj                               ) : LxResult;

    function Root
             (  out VObj                               ) : LxResult;

    function ItemTypeCount                               : UInt32  ;

    function ItemTypeByIndex
             (      Index          : UInt32;
                    &Type          : PLXtItemType      ) : LxResult;

    function ItemTypeLookup
             (const Name           : PChar;
                    &Type          : PLXtItemType      ) : LxResult;

    function ItemTypeName
             (      &Type          : LXtItemType       ;
              const Name           : PPChar            ) : LxResult;

    function ItemTypeTest
             (      What           ,
                    IsA            : LXtItemType       ) : LxResult;

    function ItemTypeSuper
             (      &Type          : LXtItemType       ;
                    Super          : PLXtItemType      ) : LxResult;

    function ItemTypeCommonChannels
             (      Item1          ,
                    Item2          : IUnknown          ;
                    Count          : PUInt32           ) : LxResult;

    function ItemSubTypeCount
             (      &Type          : LXtItemType       ;
                    Count          : PUInt32           ) : LxResult;

    function ItemSubTypeByIndex
             (      &Type          : LXtItemType       ;
                    Index          : UInt32            ;
              const SubType        : PPChar            ) : LxResult;

    function ChannelVectorSize
             (      Mode           ,
                    Size           : UInt32            ) : LxResult;

    function ChannelVectorTextHints
             (const Hints          : PPLXtTextValueHint) : LxResult;

    function CreateScene
             (  out VObj                               ) : LxResult;

    function DestroyScene
             (      Scene          : IUnknown          ) : LxResult;

    function SubSceneAdd
             (      Scene          ,
                    Other          : IUnknown          ;
                    RefItems       : UInt32            ) : LxResult;

    function SubSceneLoad
             (      Scene          : IUnknown          ;
              const Path           : PChar             ;
                    Monitor        : IUnknown          ;
                out VObj                               ) : LxResult;

    function GetMeshInstSourceItem
             (      Inst           : IUnknown          ;
                out VObj                               ) : LxResult;

    function MeshInstanceCount
             (      Mesh           : IUnknown          ) : Integer ;

    function MeshInstanceByIndex
             (      Mesh           : IUnknown          ;
                    Index          : Integer           ;
                out VObj                               ) : LxResult;

    function LoadImage
             (      Scene          : IUnknown          ;
              const Name           : PChar             ;
                    Flags          : PUInt32           ;
                    Monitor        : IUnknown          ;
                out VObj                               ) : LxResult;

    function GetReplicatorEnumerator
             (      ReplicatorItem : IUnknown          ;
                out VObj                               ) : LxResult;
  end;

  ILxScene2Service = interface
  [LXu_SCENE2SERVICE]
    function ScriptQuery
             (  out VObj                          ) : LxResult;

    function Root
             (  out VObj                          ) : LxResult;

    function LoadImage
             (      Scene     : IUnknown          ;
              const Name      : PChar             ;
                    Flags     : PUInt32           ;
                    Monitor   : IUnknown          ;
                out VObj                          ) : LxResult;

    function ItemTypeCount                          : UInt32  ;

    function ItemTypeByIndex
             (      Index     : UInt32            ;
                    &Type     : PLXtItemType      ) : LxResult;

    function ItemTypeLookup
             (const Name      : PChar             ;
                    &Type     : PLXtItemType      ) : LxResult;

    function ItemTypeName
             (      &Type     : LXtItemType       ;
              const Name      : PPChar            ) : LxResult;

    function ItemTypeTest
             (      What      : LXtItemType       ;
                    IsA       : LXtItemType       ) : LxResult;

    function ItemTypeSuper
             (      &Type     : LXtItemType       ;
                    Super     : PLXtItemType      ) : LxResult;

    function ItemTypeCommonChannels
             (      Item1     ,
                    Item2     : IUnknown          ;
                    Count     : PUInt32           ) : LxResult;

    function ItemSubTypeCount
             (      &Type     : LXtItemType       ;
                    Count     : PUInt32           ) : LxResult;

    function ItemSubTypeByIndex
             (      &Type     : LXtItemType       ;
                    Index     : UInt32            ;
              const SubType   : PPChar            ) : LxResult;

    function ChannelVectorSize
             (      Mode      : UInt32            ;
                    Size      : PUInt32           ) : LxResult;

    function ChannelVectorTextHints
             (const Hints     : PPLXtTextValueHint) : LxResult;

    function SubSceneAdd
             (      Scene     ,
                    Other     : IUnknown          ;
                    RefItems  : UInt32            ) : LxResult;

    function SubSceneLoad
             (      Scene     : IUnknown          ;
              const Path      : PChar             ;
                    Monitor   : IUnknown          ;
                out VObj                          ) : LxResult;

    function Import
             (      Scene     : IUnknown          ;
              const Path      : PChar             ;
                    Monitor   : IUnknown          ) : LxResult;

    function WorldTransform
             (      Locator   : IUnknown          ;
                    Time      : Double            ;
                    Xfrm      : LXtMatrix         ;
                    Pos       : LXtVector         ) : LxResult;

    function GetTransformItem
             (      Locator   : IUnknown          ;
                    &Type     : LXtTransformType  ;
                out VObj                          ) : LxResult;

    function AddTransformItem
             (      Locator   : IUnknown          ;
                    &Type     : LXtTransformType  ;
                out VObj                          ;
                    Index     : PUInt32           ) : LxResult;

    function SetTransformVector
             (      Locator   ,
                    ChanWrite : IUnknown          ;
                    &Type     : LXtTransformType  ;
                    Value     : LXtVector         ) : LxResult;

    function AddPreTransformItem
             (      Locator   ,
                    ChanWrite : IUnknown          ;
                    &Type     : LXtTransformType  ;
                    Value     : LXtVector         ;
                out VObj                          ;
                    Index     : PUInt32           ) : LxResult;

    function AddPostTransformItem
             (      Locator   ,
                    ChanWrite : IUnknown          ;
                    &Type     : LXtTransformType  ;
                    Value     : LXtVector         ;
                out VObj                          ;
                    Index     : PUInt32           ) : LxResult;

    function GetMeshInstSourceItem
             (      Inst      : IUnknown          ;
                out VObj                          ) : LxResult;

    function MeshInstanceCount
             (      Mesh      : IUnknown          ) : Integer;

    function MeshInstanceByIndex
             (      Mesh      : IUnknown          ;
                    Index     : Integer           ;
                out VObj                          ) : LxResult;

    function SetTarget
             (      Locator   ,
                    Target    : IUnknown          ;
                out VObj                          ) : LxResult;

    function PrependTransformItem
             (      Locator   ,
                    ChanWrite : IUnknown          ;
                    &Type     : LXtTransformType  ;
                    Value     : LXtVector         ;
                out VObj                          ;
                    Index     : PUInt32           ) : LxResult;

    function AppendTransformItem
             (      Locator   ,
                    ChanWrite : IUnknown          ;
                    &Type     : LXtTransformType  ;
                    Value     : LXtVector         ;
                out VObj                          ;
                    Index     : PUInt32           ) : LxResult;
  end;

  ILxScene = interface
  [LXu_SCENE]
    function ItemRootType                                        : LXtItemType;
    function Filename          (const Filename   : PPChar      ) : LxResult   ;
    function FriendlyFilename  (      Flags      : UInt32      ;
                                const Filename_  : PPChar      ) : LxResult   ;
    function FileFormat        (const Format     : PPChar      ) : LxResult   ;
    function Changed           (      Changed    : UInt32      ) : LxResult   ;
    function HasChanged        (      NumChanges : PUInt32     ) : LxResult   ;
    function Parent            (  out VObj                     ) : LxResult   ;
    function SubSceneCount     (      &Type      : LXtItemType ;
                                      Count      : PUInt32     ) : LxResult   ;
    function SubSceneByIndex   (      &Type      : LXtItemType ;
                                      Index      : UInt32      ;
                                  out VObj                     ) : LxResult   ;
    function LoadFlags                                           : UInt32     ;
    function Channels          (const Name       : PChar       ;
                                      Time       : Double      ;
                                  out VObj                     ) : LxResult   ;
    function ItemCount         (      &Type      : LXtItemType ;
                                      Count      : PUInt32     ) : LxResult   ;
    function  ItemByIndex      (      &Type      : LXtItemType ;
                                      Index      : UInt32      ;
                                  out VObj                     ) : LxResult   ;
    function ItemLookup        (const ID         : PChar       ;
                                  out VObj                     ) : LxResult   ;
    function ItemCountByTypes  (      Types      : PLXtItemType;
                                      Count      : PUInt32     ) : LxResult   ;
    function ItemByIndexByTypes(      Types      : PLXtItemType;
                                      Index      : UInt32      ;
                                  out VObj                     ) : LxResult   ;
    function AnyItemOfType     (      &Type      : LXtItemType ;
                                  out VObj                     ) : LxResult   ;
    function ItemLocalize      (      Item       : IUnknown    ;
                                  out VObj                     ) : LxResult   ;
    function ItemAdd           (      &Type      : LXtItemType ;
                                  out VObj                     ) : LxResult   ;
    function ItemDuplicate     (      Item       : IUnknown    ;
                                  out VObj                     ) : LxResult   ;
    function ItemAddReference  (      Item       : IUnknown    ;
                                  out VObj                     ) : LxResult   ;
    function GraphLookup       (const Name       : PChar       ;
                                  out VObj                     ) : LxResult   ;
    function GraphCount        (      Count      : PInteger    ) : LxResult   ;
    function GraphByIndex      (      Index      : UInt32      ;
                                  out VObj                     ) : LxResult   ;
    function ItemRemove        (      Item       : IUnknown    ) : LxResult   ;
    function Import            (const Path       :  PChar      ;
                                      Monitor    : IUnknown    ) : LxResult   ;
    function EvalModInvalidate (const ModName    : PChar       ) : LxResult   ;
    function EvalModReset      (const ModName    : PChar       ) : LxResult   ;
    function ItemReplace       (      Item       : IUnknown    ;
                                      &Type      : Integer     ;
                                  out VObj                     ) : LxResult   ;
    function SetupMode                                           : LxResult   ;
    function SetupChannels     (  out VObj                     ) : LxResult   ;
    function ItemLookupIdent   (const ID         : PChar       ;
                                  out VObj                     ) : LxResult   ;
    function ItemLookupImported(const ID         : PChar       ;
                                  out VObj                     ) : LxResult   ;
  end;

  ILxItem = interface
  [LXu_ITEM]
    function  &Type                                   : LXtItemType;

    function  TestType
              (      Type_      : LXtItemType       ) : LxResult   ;

    function  TestTypes
              (      Types      : LXtItemType       ) : LxResult   ;

    function  Ident
              (const Ident      : PPChar            ) : LxResult   ;

    function  SetIdent
              (const Ident_     : PPChar            ) : LxResult   ;

    function  Name
              (const Name       : PPChar            ) : LxResult   ;

    function  SetName
              (const Name_      : PPChar            ) : LxResult   ;

    function  UniqueName
              (const Name_      : PPChar            ) : LxResult   ;

    function  UniqueIndex
              (      Index      : PUInt32           ) : LxResult   ;

    function  SetUniqueIndex
              (      Index      : PUInt32           ) : LxResult   ;

    function  Parent
              (  out VObj                           ) : LxResult   ;

    function  SetParent
              (      Parent_    : IUnknown          ) : LxResult   ;

    function  SubCount
              (      Count      :  PUInt32          ) : LxResult   ;

    function  SubByIndex
              (      Index      : UInt32            ;
                 out VObj                           ) : LxResult   ;

    function  Root
              (  out VObj                           ) : LxResult   ;

    function  Context
              (  out VObj                           ) : LxResult   ;

    function  Reference
              (  out VObj                           ) : LxResult   ;

    function  IsReferenced                            : LxResult   ;

    function  Source
              (  out VObj                           ) : LxResult   ;

    function  SetSource
              (      Source_    : IUnknown          ) : LxResult   ;

    function  ChannelCount
              (      Count      : PUInt32           ) : LxResult   ;

    function  ChannelLookup
              (const Name_      : PChar             ;
                     Index      : PUInt32           ) : LxResult   ;

    function  ChannelName
              (      Index      : UInt32            ;
               const Name_      : PPChar            ) : LxResult   ;

    function  ChannelType
              (      Index      : UInt32            ;
                     Type_      : PUint32           ) : LxResult   ;

    function  ChannelVectorMode
              (      Index      : UInt32            ;
                     Mode       : PUInt32           ;
                     Components : PUInt32           ) : LxResult   ;

    function  ChannelStorageType
              (      Index      : UInt32            ;
               const Type_      : PPChar            ) : LxResult   ;

    function  ChannelEvalType
              (      Index      : UInt32            ;
               const Type_      : PPChar            ) : LxResult   ;

    function  ChannelGradient
              (      Index      : UInt32            ;
               const Input      : PPChar            ;
               const Output     : PPChar            ) : LxResult   ;

    function  ChannelIntHint
              (      Index      : UInt32            ;
               const Hints      : PPLXtTextValueHint) : LxResult   ;

    function  ChannelPackage
              (      Index      : UInt32            ;
               const Package    : PPChar            ) : LxResult   ;

    function  PackageAdd
              (const Package    : PChar             ) : LxResult   ;

    function  PackageTest
              (const Package    : PChar             ) : LxResult   ;

    function  PackageStartIndex
              (const Package    : PChar             ;
                     Index      : PUInt32           ) : LxResult   ;

    function  PackageRemove
              (const Package    : PPChar            ) : LxResult   ;

    function  ChannelAdd
              (      Whatever   : Integer           ) : LxResult   ;

    function  GetTag
              (      Type_      : LXtID4            ) : PChar      ;

    function  SetTag
              (      Type_      : LXtID4            ;
               const Tag        : PChar             ) : LxResult   ;

    procedure InvalidateName                          ;

    function  WasLoaded
              (      Test       : UInt32            ) : LxResult   ;
  end;

  ILxSceneGraph = interface
  [LXu_SCENEGRAPH]
    function Name       (const Name  : PPChar  ) : LxResult;
    function Context    (  out VObj            ) : LxResult;
    function RootCount  (      Count : PInteger) : LxResult;
    function RootByIndex(      Index : Integer ;
                           out VObj            ) : LxResult;
    function RootFirst  (  out VObj            ) : LxResult;
    function RootNext   (  out VObj            ) : LxResult;
    function RootSetPos (      Item  : IUnknown;
                               Pos   : Integer ) : LxResult;
    function RootRemove (      Item  : IUnknown) : LxResult;
  end;

  ILxItemGraph = interface
    [LXu_ITEMGRAPH]
    function AddLink   (    From      : IUnknown;
                            &To       : IUnknown) : LxResult;
    function SetLink   (    From      : IUnknown;
                            FromIndex : Integer ;
                            &To       : IUnknown;
                            ToIndex   : Integer ) : LxResult;
    function DeleteLink(    From      : IUnknown;
                            &To       : IUnknown) : LxResult;
    function FwdCount  (    Item      : IUnknown;
                            Count     : PUInt32 ) : LxResult;
    function FwdByIndex(    Item      : IUnknown;
                            Index     : UInt32  ;
                        out VObj                ) : LxResult;
    function RevCount  (    Item      : IUnknown;
                            Count     : PUInt32 ) : LxResult;
    function RevByIndex(    Item      : IUnknown;
                            Index     : UInt32  ;
                        out VObj                ) : LxResult;
  end;

  ILxChannelGraph = interface
  [LXu_CHANNELGRAPH]
    function AddLink   (    From      : IUnknown;
                            FromChan  : Integer ;
                            &To       : IUnknown;
                            ToChan    : Integer ) : LxResult;
    function SetLink   (    From      : IUnknown;
                            FromChan  : Integer ;
                            FromIndex : Integer ;
                            &To       : IUnknown;
                            ToChan    : Integer ;
                            ToIndex   : Integer ) : LxResult;
    function DeleteLink(    From      : IUnknown;
                            FromChan  : Integer ;
                            &To       : IUnknown;
                            ToChan    : Integer ) : LxResult;
    function FwdCount  (    Item      : IUnknown;
                            Channel   : Integer ;
                            Count     : PUInt32 ) : LxResult;
    function FwdByIndex(    Item      : IUnknown;
                            Channel   : Integer ;
                            Index     : UInt32  ;
                        out VObj                ;
                            ObjChan   : PInteger) : LxResult;
    function RevCount  (    Item      : IUnknown;
                            Channel   : Integer ;
                            Count     : PUInt32 ) : LxResult;
    function RevByIndex(    Item      : IUnknown;
                            Channel   : Integer ;
                            Index     : UInt32  ;
                        out VObj                ;
                            ObjChan   : PInteger) : LxResult;
  end;

implementation

end.

